#ifndef SINGLETONBASE_H
#define SINGLETONBASE_H

#define DECLARE_SINGLETON(classname) /*place in .h*/\
private: \
static classname* m_pThis; \
classname() {} \
class Guard \
{ \
public: \
~Guard() \
{ \
if(classname::m_pThis != 0 ) \
delete classname::m_pThis; \
} \
}; \
friend class Guard; \
public: \
static classname* getInstance() \
{ \
static Guard guard; \
if(classname::m_pThis == 0) \
{ \
	classname::m_pThis = new classname(); \
} \
return classname::m_pThis; \
} 

#define DEFINE_SINGLETON(classname) /*Place in .cpp*/ \
classname* classname::m_pThis=0;

#endif //SINGLETONBASE_H